#if !defined JJDistanceMap_H
#define JJDistanceMap_H

#include		<assert.h>
#include		<math.h>
#include		<memory.h>
#include		<stdio.h>
#include		<stdlib.h>
#include		<string.h>
#include		"FusionGlobal.h"
#include        "maskvolume.h"

#define	NAMESIZE	20

//#define	MINVALUE	(-32767 / 2)
//#define	MAXVALUE	(32767 >> 1)
#define	MINVALUE	(-128)
#define	MAXVALUE	(255)
#define	CONTOUR		0

#define	FALSE		0
#define	TRUE		1

typedef	struct	txtresol3D {
	short	Ru;
	short	Rv;
	short	Rw;
} TxtResol3D;

class JJDistanceMap
{
private:
	unsigned char*				m_pDistanceMap;
	RxMaskVolume*				m_pBinaryVolume;
	unsigned int*				m_pDBF;
	unsigned char				m_iMaxDistance;
	float*						m_pLongDistanceMap;

public:
	short					m_VolX;
	short					m_VolY;
	short					m_VolZ;
	double					m_lfZRatioXY;

public:
	JJDistanceMap();
	void CreateDistanceMap(RxMaskVolume* pRefBinary, int iVolX, int iVolY, int iVolZ);
	void CreatePropagationDistanceMap(RxMaskVolume* pRefBinary, int iVolX, int iVolY, int iVolZ, int iMaxDistance);
	void CreateEuclideanDistanceMap(RxMaskVolume* pRefBinary, int iVolX, int iVolY, int iVolZ);

	~JJDistanceMap();
	void		DestroyDistanceMap(void);
	void		Initialize(void);
	void		CalDistance(void);
	void		CalPropagationDistance(void);
	void		CalPropagationDistanceZRatio(void);
	void		CalEuclideanDistance(void);

	void		PrintDistanceMap(void);

	int			maximum(int a, int b);
	int			minimum(int a, int b);
	int			GetDistance(int iX, int iY, int iZ);
	int			GetPropagationDistance(int iX, int iY, int iZ);
	float		GetPropagationDistanceZRatio(int iX, int iY, int iZ);
	int			GetEuclideanDistance(int iX, int iY, int iZ);
	short		Min(short param1, short param2);
};

#endif